package com.yanqu.road.server.cmd.activity.douluodalu;

import com.yanqu.road.pb.activity.douluodalu.DouLuoDaLuProto;
import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.douluodalu.CrossDouLuoDaLuMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

import static com.yanqu.road.utils.YanQuMessageUtils.buildMessage;


@Cmd(code = Protocol.C_DOU_LUO_DA_LU_EVENT_HANDLE, desc = "事件处理")
public class CrossDouLuoDaLuEventHandleCmd extends CrossUnionCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        DouLuoDaLuProto.DouLuoDaLuEventHandleCrossReqMsg reqMsg = DouLuoDaLuProto.DouLuoDaLuEventHandleCrossReqMsg.parseFrom(packet.getBytes());
        int eventId = 0;
        if(reqMsg.hasEventId()){
            eventId = reqMsg.getEventId();
        }
        MessageHelper.sendPacket(serverId, packet.getPlayerId(), buildMessage(Protocol.S_DOU_LUO_DA_LU_EVENT_HANDLE_FROM_CROSS,
                CrossDouLuoDaLuMgr.handleEvent(reqMsg.getActivityId(), packet.getPlayerId(), reqMsg.getAction(),
                        reqMsg.hasConsume() ? reqMsg.getConsume() : "", packet.getBytes(), eventId)));

    }

    @Override
    public void sendData() {

    }
}
